package com.atguigu.gmallre.mock.stage;

import com.atguigu.gmallre.mock.factory.UserSession;
import com.atguigu.gmallre.mock.log.AppCommon;
import com.atguigu.gmallre.mock.log.AppDisplay;
import com.atguigu.gmallre.mock.log.AppMain;
import com.atguigu.gmallre.mock.log.AppPage;
import com.atguigu.gmallre.mock.log.enums.PageId;
import com.atguigu.gmallre.mock.service.LogService;
import com.atguigu.mock.util.LogUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("search")
public class SearchStage implements Stage{

    @Autowired
    LogService logService;

    @Override
    public boolean handle() {
        AppMain appMain = mainlog();
        logService.doLog(appMain) ;
        UserSession.setLastPageId(PageId.search);
        return true;
    }

    private  AppMain  mainlog(){
        AppCommon appCommon = UserSession.getAppCommon();
        AppPage appPage = AppPage.builder().page_id(PageId.search).build();

        List<AppDisplay> appDisplayList = AppDisplay.builder().pos_id(3).max_size(10).buildList();

        UserSession.addTimeByDuringTime(appPage.getDuring_time());
        UserSession.setLastDisplay(appDisplayList);
        Long ts= UserSession.getCurDateTime().getTime();
        AppMain appMain = AppMain.builder().common(appCommon).page(appPage).displays(appDisplayList).ts(ts).build();
        return  appMain;



    }
}
